<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTiebaCrawlerStatusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tieba_crawler_status', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('user_id')->nullable()->index();
            $table->unsignedBigInteger('post_id');
            $table->unsignedInteger('repository_id')->nullable()->index();
            $table->integer('current_page')->default(0)->nullable();
            $table->integer('total_page')->default(0)->nullable();
            $table->tinyInteger('status')->comment('0:on_queue;1:preparing;2:fetching;3:fetched;4:done;5:error')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tieba_crawler_status');
    }
}
